function Http(){
    let xmlhttp = new XMLHttpRequest();
    return function(method,url,data,success,error){
        xmlhttp.open(method,url);
        if(method == 'GET'){
            xmlhttp.send();

        }else{
            xmlhttp.setRequestHeader("Content-Type","application/json");
            xmlhttp.send(JSON.stringify(data))
        }
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
                success(xmlhttp.responseText);
            }else{
                error()
            } 
        }
    }
}